﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccess
{
    public class Login_DA
    {
        QLHocSinhDataContext ql = new QLHocSinhDataContext();
        public string Dangnhap(string user, string pass)
        {
            string q = "";
            if (user != "" || pass != "")
            {
                int k = ql.TAIKHOANs.Where(dn => dn.USERNAME == user).Where(lg => lg.PASSWORD == pass).Count();
                if (k != 0)
                {
                    q = ql.TAIKHOANs.Where(dn => dn.USERNAME == user).Where(lg => lg.PASSWORD == pass).FirstOrDefault().QUYEN;
                }
            }
            return q;
        }
        //..........Doi pass.........
        public bool Doipass(string user, string pass)
        {
            TAIKHOAN t = ql.TAIKHOANs.Where(p=>p.USERNAME==user).FirstOrDefault();
            t.PASSWORD = pass;
            try
            {
                ql.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool Ktpass(string pass)
        {
            int i = ql.TAIKHOANs.Where(p => p.PASSWORD == pass).Count();
            if (i > 0)
                return true;
            else
                return false;
        }
    }
}
